<?php
namespace Admin\View;

use Zend\View\Helper\AbstractHelper;
use Zend\Authentication\AuthenticationService;
use Zend\Authentication\Storage\Session as SessionStorage;

class Helper extends AbstractHelper
{

	protected $route;

	public function __construct($route)
	{
		$this->route = $route;
	}
	
	public function getRoute() {
		return $this->route;
	}

	public function getParams()
	{
		$controller = $this->route->getParams();
		return $controller;
	}
	
	public function getController()
	{
		$params = $this->getParams();
		return $params['controller'];
	}
	
	public function getAction()
	{
		$params = $this->getParams();
		return $params['action'];
	}
	
	public function getRouteName() {
		return $this->route->getMatchedRouteName();
	}

	public function makeFlashMsg($data) {
		if(!empty($data['type'])) {
			$class = 'alert-' . $data['type'];
		} else {
			$class = '';
		}
		$html = '
		<div class="alert ' . $class . '">
			<button type="button" class="close" data-dismiss="alert">×</button>
			<div>' . $data['text'] . '</div>
		</div>
		';
		return $html;
	}
	
	public function getAuthUser() {
		$auth = new AuthenticationService();
		$auth->setStorage(new SessionStorage('someNamespace'));
		return $auth->getIdentity();
	}
	
}
